package com.test.mytest.beans;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;

public class Person implements BeanFactoryAware, BeanNameAware, InitializingBean, DisposableBean {

    private String name;

    private String mobile;

    public Person() {
        super();
        System.out.println("[构造器] 调用Person的构造器实例化");
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        System.out.println("[属性注入] name="+name);
        this.name = name;
    }

    public String getMobile() {
        return mobile;
    }

    public void setMobile(String mobile) {
        System.out.println("[属性注入] mobile="+mobile);
        this.mobile = mobile;
    }

    @Override
    public void destroy() throws Exception {
        System.out.println("[接口DisposableBean.destroy() ]");
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println("[接口InitializingBean.afterPropertiesSet() ]");
    }

    @Override
    public void setBeanName(String name) {
        System.out.println("[接口BeanNameAware.setBeanName() ]");
    }

    @Override
    public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
        System.out.println("[接口BeanFactoryAware.setBeanFactory() ]");
    }

    public void myInit(){
        System.out.println("[init-method]调用<bean>的init-method属性指定的初始化方法");
    }

    public void myDestory() {
        System.out.println("[destroy-method]调用<bean>的destroy-method属性指定的销毁方法");
    }

}